package phoenics.manpads.stinger.config;

import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ResourceUtils;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
 * @author Phoenics Chow
 * on 2019年01月21日
 */
public class IconConfig {
    private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(IconConfig.class);
    public static ImageView projectIcon(){
        return theIcon("view/img/database.png");
    }
    public static ImageView tableIcon(){
        return theIcon("view/img/table.png");
    }
    public static ImageView raIcon(){
        return theIcon("view/img/ra.png");
    }

    private static ImageView theIcon(String imgPath){
        ImageView folderIcon = new ImageView();
        FileInputStream keyStoreIn = null;
        try {
            keyStoreIn = new FileInputStream(ResourceUtils.getFile("classpath:"+imgPath));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        Image folderImage = new Image(keyStoreIn);
        folderIcon.setImage(folderImage);
        folderIcon.setFitWidth(16);
        folderIcon.setFitHeight(16);
        return folderIcon;
    }
}
